'use strict';

const Controller = require('egg').Controller;

class HomeController extends Controller {
  async index() {
    
    this.ctx.body = 'api hello'
  }

  async getArticleList(){
    const {ctx} = this
    const resulet = await ctx.service.article.getArticleList()
    ctx.body={
         data:resulet
     }
  }
  
  async getAriticleById(){
    const {ctx} = this
    console.log(ctx.params.id)
    const resulets = await ctx.service.article.getAriticleById(ctx.params.id)
 
    ctx.body={
      data:resulets
    }
  }
  
  //得到首页的类别
  async getTypeInfo(){
    const {ctx} = this
    const result = await ctx.service.article.getTypeInfo()
    ctx.body={
      data:result
    }
  }

   //根据文字类别id 获取列表
   async getListById(){
     const {ctx} = this
     const result = await ctx.service.article.getListById(ctx.params.id)
     ctx.body={
       data:result
     }
   }

}

module.exports = HomeController;
